package com.java2104.mapper;

import com.java2104.entity.Document;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DocumentMapper {

    /*private Integer id;
    private String title;//标题
    private String filename;//文档名称
    private String remark;//文档描述
    @JsonFormat(pattern = "yyyy年MM月dd日 HH:mm:ss",timezone = "GMT+8")
    private Timestamp createDate;//创建时间
    private User createUser;//createUser.id =>user_id*/
    //添加文档记录的方法
    @Insert("insert into document_inf value(null,#{title},#{filename},#{remark},#{createDate},#{createUser.id})")
    int insert(Document document);

    public List<Document> findByTitle(String title);

    @Select("select * from document_inf where id=#{param1}")
    Document findByPrimaryKey(Integer id);

    @Update("update document_inf set title=#{title},remark=#{remark} where id=#{id}")
    int updateByPrimaryKey(Document document);

    int batchDelete(List<Integer> ids);
}
